#include <stdio.h>
#include "magic.h"

#define MAX_LEN   15

int main()
{
	int n;
	int buf[MAX_LEN * MAX_LEN];
    int result;

	printf("Please enter the row/col of the magic: ");
	result = scanf("%d",&n);
	if (result < 0){
       perror("scanf error"); 
       return ERROR;
    }

	if (n < 0 || n > MAX_LEN){
		fprintf(stderr,"n = %d, The row/col must be from 0 to %d\n", n, MAX_LEN);
		return ERROR;
	}

	if (magic(buf,n,n)){
		show_magic(buf,n,n);
		return OK;
	}
	return ERROR;
}

